package tpi.gui.pages

import dominio.factory.FactoryGame
import org.apache.wicket.markup.html.WebPage
import org.apache.wicket.markup.html.form.Form
import org.apache.wicket.model.CompoundPropertyModel
import org.uqbar.wicket.xtend.WicketExtensionFactoryMethods
import org.uqbar.wicket.xtend.XButton
import tpi.gui.pages.expedientes.EditarExpedientesPage
import tpi.gui.pages.mapamundi.MapamundiPage
import tpi.gui.pages.caso.InicioCasoPage

class InicioPage extends WebPage {
		
	extension WicketExtensionFactoryMethods = new WicketExtensionFactoryMethods
	@Property FactoryGame factory
	
	new() {
		this.factory = new FactoryGame
		val Form<FactoryGame> form = new Form<FactoryGame>("inicioForm", new CompoundPropertyModel<FactoryGame>(this.factory))
		form.addChild(new XButton("caso").onClick = [| verCaso()])
		form.addChild(new XButton("mapamundi").onClick = [| edicionMapamundi()])
		form.addChild(new XButton("expedientes").onClick = [| edicionExpedientes()])
		addChild(form)
	}
	
	def edicionMapamundi() {
		responsePage = new MapamundiPage(factory.mapamundi,this)
	}

	def edicionExpedientes() {
		responsePage = new EditarExpedientesPage(factory.expedientes, this)
	}
	
	def verCaso() {
		responsePage = new InicioCasoPage(factory.caso,this)
	}
	
}